package com.zzyl.nursing.service.impl;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzyl.nursing.domain.pojo.Reservation;
import com.zzyl.nursing.service.IReservationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

/**
@author sjqn
*/
@Component
@Slf4j
public class MyTask {
    @Autowired
    private IReservationService reservationService;
    /**
     * 定时任务
     */
    @Scheduled(cron = "0 16,46 * * * ?")
    public void executeTask(){
        LocalDateTime now = LocalDateTime.now();
        reservationService.update(Wrappers.<Reservation>lambdaUpdate()
                .set(Reservation::getStatus, 3)
                .eq(Reservation::getStatus, 0)
                .lt(Reservation::getTime,now));
    }
}